package dp.gr03.payroll.generalTransactions;

import dp.gr03.payroll.exception.PayRollException;
import dp.gr03.payroll.payrollApplication.Transaction;
import dp.gr03.payroll.payrollDatabase.PayrollDatabase;

public class DeleteEmployeeTransaction implements Transaction
{
    
    protected int employeeId;
    
    public DeleteEmployeeTransaction(int employeeId)
    {
        this.employeeId = employeeId;
    }

    @Override
    public void execute() throws PayRollException
    {
        PayrollDatabase db = PayrollDatabase.getInstance();
        if(db.employeeExists(employeeId)){
            db.deleteEmployee(employeeId);
        }
        else{
            throw new PayRollException("This user ID doesn't exist.");
        }
    }

}
